﻿using AutoMapper;
using Common.Communal;
using ERP.Domain.SalesManagement;
using MediatR;
using Sell.Api.Write.Application.Command.SalesManagementCommand;
using Sell.Services.Verifications;

namespace Sell.Api.Write.Application.CommandHandlers.SalesManagementCommandHandlers
{
    public class VerificationAddCommandHandlers : IRequestHandler<VerificationAddCommand, ApiResult<int>>
    {
        private readonly IVerificationServices services;
        private readonly IMapper mapper;
        public VerificationAddCommandHandlers(IVerificationServices _services, IMapper _mapper)
        {
            services= _services;
            mapper= _mapper;
        }
        /// <summary>
        /// 采购核价添加
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<ApiResult<int>> Handle(VerificationAddCommand request, CancellationToken cancellationToken)
        {
            var list = mapper.Map<Verification>(request);
            return await services.AddVerification(list);
        }
    }
}
